{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Set up proxy to access hugging face library\n",
    "import os\n",
    "\n",
    "os.environ[\"HTTP_PROXY\"] = \"http://proxy-dku.oit.duke.edu:3128\"\n",
    "os.environ[\"HTTPS_PROXY\"] = \"http://proxy-dku.oit.duke.edu:3128\"\n",
    "\n",
    "### import packages\n",
    "from transformers import AutoProcessor,WavLMModel, AutoModel\n",
    "import torch\n",
    "from datasets import load_dataset\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\Beilong Tang\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\huggingface_hub\\file_download.py:149: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\\Users\\Beilong Tang\\.cache\\huggingface\\hub\\models--microsoft--wavlm-large. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.\n",
      "To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to see activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development\n",
      "  warnings.warn(message)\n",
      "c:\\Users\\Beilong Tang\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\torch\\_utils.py:776: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly.  To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()\n",
      "  return self.fget.__get__(instance, owner)()\n"
     ]
    }
   ],
   "source": [
    "model = AutoModel.from_pretrained(\"microsoft/wavlm-large\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "### randomly generate audio\n",
    "audio = torch.randn(1,93680)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wav2Vec2BaseModelOutput(last_hidden_state=tensor([[[-0.3779,  0.1689, -0.5098,  ..., -0.3501,  0.2076,  0.0520],\n",
      "         [-0.0494,  0.2058, -0.4268,  ..., -0.2183,  0.0703, -0.2417],\n",
      "         [-0.1458,  0.1041, -0.4468,  ..., -0.1980,  0.1091, -0.3634],\n",
      "         ...,\n",
      "         [-0.4385,  0.2272, -0.0335,  ..., -0.2584, -0.0709, -0.1087],\n",
      "         [-0.4625,  0.0871, -0.0681,  ..., -0.2652,  0.0209, -0.0880],\n",
      "         [-0.4370, -0.0445, -0.1561,  ..., -0.1047,  0.1379,  0.0070]]],\n",
      "       grad_fn=<NativeLayerNormBackward0>), extract_features=tensor([[[ 0.0886,  1.0729,  0.0368,  ..., -0.3336,  0.0246,  0.4612],\n",
      "         [-0.1674, -0.3108, -0.0825,  ..., -0.3906,  0.0259,  0.5483],\n",
      "         [-0.0128,  0.4460,  0.0138,  ..., -0.0869,  0.0169,  0.3112],\n",
      "         ...,\n",
      "         [-0.0462, -0.1789, -0.1183,  ...,  0.0227,  0.0323,  0.2081],\n",
      "         [ 0.3753,  0.6175, -0.0078,  ..., -0.1805,  0.0325,  0.2164],\n",
      "         [-0.1027, -0.3298,  0.0190,  ..., -0.2004,  0.0244,  0.2922]]],\n",
      "       grad_fn=<NativeLayerNormBackward0>), hidden_states=None, attentions=None)\n"
     ]
    }
   ],
   "source": [
    "output = model(audio)\n",
    "print(output)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
